/**
 * Object.preventExtensions(obj)
 * 不可添加新属性
 * 可删除属性，可修改属性值
 * 可修改属性描述符号
 */

const obj = { name: 'jeff' };
console.log(
  'before preventExtensions: ',
  Object.getOwnPropertyDescriptors(obj)
);

Object.preventExtensions(obj);

obj.age = 23;

console.log('obj is extensible: ', Object.isExtensible(obj));
console.log('after add new property obj: ', obj);
console.log('after preventExtensions: ', Object.getOwnPropertyDescriptors(obj));

obj.name = 'feng';

console.log('after change value obj: ', obj);

Object.defineProperty(obj, 'name', { enumerable: false });
console.log(
  'after change writable to false: ',
  Object.getOwnPropertyDescriptors(obj)
);

delete obj.name;

console.log('after delete name obj: ', obj);
